from typing import Optional

from sqlalchemy import Enum
from sqlmodel import SQLModel, Field, Relationship

from app.model.mixins import TimeMixin


class Sex(str, Enum):
    男 = "男"
    女 = "女"


class Person(SQLModel, TimeMixin, table=True):
    __tablename__ = "person"

    id: Optional[str] = Field(None, primary_key=True, nullable=False)
    name: str
    sex: Sex
    profile: str
    phone_number: Optional[str]
    email: Optional[str]
    subject_type: str
    exam_province: str

    users: Optional["Users"] = Relationship(
        sa_relationship_kwargs={'uselist': False}, back_populates="person")
